package com.example.kotlincoroutines.kotlin

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

/**
 * launch 源码详解
 * CoroutineStart.ATOMIC 立即执行
 *
 * CoroutineStart.LAZY
 */

@OptIn(ExperimentalStdlibApi::class)
fun main(): Unit = runBlocking(Dispatchers.IO) {

    val job = launch(start = CoroutineStart.ATOMIC) {
        println("hello")
//        delay(1000)
        println(coroutineContext.get(CoroutineDispatcher).toString())
        println("end")

    }
    job.cancel()
}